#pragma once

#include <gtl/thread/locker.h>

namespace gtl
{

class event
{
	event(const event&);
	event& operator=(const event&);

public:
	event(bool manual = false, const tchar* name = NULL)
	{
		m_event = CreateEvent(NULL, manual, TRUE, name);
	}

	~event()
	{
		unlock();
		CloseHandle(m_event);
	}

public:
	void lock()
	{
		WaitForSingleObject(m_event, INFINITE);
		ResetEvent(m_event);
	}

	void unlock()
	{
		SetEvent(m_event);
	}

protected:
	HANDLE m_event;
};


} // end of namespace gtl